package commands;

import nanoxml.XMLElement;
import utils.ITransmittable;

/**
 * This command represents the login details of a client,
 * sent to the DB for confirmation.
 */
public class CommandUserLogon implements ITransmittable {

	private final static String ATTR_USER_NAME = "Username";
	private final static String ATTR_USER_PASS = "Userpass";	
		
	private String username = null; 
	private String password = null;
	
	public CommandUserLogon (String username, String password) {
		this.username = username;
		this.password = password;
	}
	public CommandUserLogon (XMLElement command) {
		this.username = (String) command.getAttribute(ATTR_USER_NAME);
		this.password = (String) command.getAttribute(ATTR_USER_PASS);		
	}
	
	@Override
	public XMLElement toXML() {
		XMLElement message = new XMLElement();
		message.setName(Commands.USER_LOGON);
		message.setAttribute(ATTR_USER_NAME, username);
		message.setAttribute(ATTR_USER_PASS, password);		
		return message;
	}
	
	public String getUsername()
	{
		return username;
	}
	
	public String getPassword()
	{
		return password;
	}
	
}
